<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>优惠劵</title>
    <script src="../js/flexible.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="./../css/coupon.css">
</head>

<body>
    <div id="header">
        <a href="">
            <h1> &lt; </h1>
        </a>
        <h1>优惠劵</h1>
        <a href="#"><img src="./../assets/images/header_app.png" alt=""></a>
    </div>
    
        <div id="uu">
            <li></li>
        </div>
    
        <div class="back">
            <a href="index.html">首页&gt;</a>
            <a href="#">优惠券</a>

        </div>
    <div id="footer">
        <div class="more">
            <a href="">更多优惠信息>></a></div>


            <div id="center">
                <span>品牌排行</span>
                <span><img src="http://chst.vip:8081/mmb/images/more.png" alt=""></span>
            </div>
        <ul>
            <li><a href="">登录</a></li>
            <li><a href="">注册</a></li>
            <li><a href="" id="goTop">返回顶部</a></li>
        </ul>
        <div class="footer-bottom">
            <div>
                <a href="">手机APP下载</a>
                <span>慢慢买手机版</span>
                <span>&nbsp;-&nbsp;掌上比价平台</span>
                <p>m.manmanbuy.com</p>
            </div>
        </div>
    </div>
</body>

</html>
<script src="./../js/ajax.js"></script>
<script>
    fetch("http://chst.vip:1234/api/getcoupon")
        .then(body => body.json())
        .then(res => {
            //    console.log(res);
            let html = "";

            res.result.forEach(item => {
                html += `
    
            <div class="body-a">
                <a href="couponproduct.html?couponid=${item.couponId}">
                    <img src="${item.couponImg}" alt="">
                    <p>${item.couponTitle}</p>
                </a>
            </div>           

    `
            })

            uu.innerHTML = html;

            //每个li注册点击事件

            let lis = document.querySelectorAll('li');

            [...lis].forEach(li => {
                li.onclick = function () {
                    let productid = this.getAttribute("productid")
                    //点击的时候要跳转到详情页
                    location.href = "./07.detail.html?productid=" + productid
                }
            })
        })
</script>